package com.cecw.scheduler;

/**
 * @author linlingxin
 * @date 2024/5/24 15:41
 */
import com.cecw.Utils.DataCrawlerUtil;
import com.cecw.dao.ProjectMapper;
import com.cecw.service.ProjectService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

@Component
public class DataCrawlerScheduler {
    private static final Logger LOGGER = LoggerFactory.getLogger(DataCrawlerScheduler.class);
    @Resource
    private ProjectMapper projectMapper;
    /**
     * cron格式：[秒] [分] [小时] [日] [月] [周] [年（非必填）]
     * 支持通配符
     */
    @Scheduled(cron = "0 0 5 * * ?")
    public void crawlData() {
        // 调用爬虫代码
        LOGGER.info("正在爬取数据...");
        // 这里调用实际的爬虫方法
        executeCrawling();
    }

    private void executeCrawling() {
        // 爬虫代码逻辑
        DataCrawlerUtil.dataCraw(projectMapper);
    }
}
